package xyz.zhno.project.commons.core.dto;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import xyz.zhno.project.commons.core.exception.ProjectException;

/**
 * @author zh_o
 * @date 2020-10-31
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ResultError {

    private String code;

    private String message;

    private Object res;

    /**
     * 错误响应
     */
    public static ResultError error(ProjectException e) {
        return ResultError.builder()
                .code(e.getCode())
                .message(e.getMessage())
                .build();
    }
}
